﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ADC.DAL;
using ADC.BL;

namespace ADC.Web
{
    public partial class ListProduct : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                BindData();
            }
        }

        private void BindData()
        {
            // Get Type
            var type = Request.Params["type"];

            List<Product> products = ProductFactory.GetAll(Convert.ToInt32(type));
            ListViewProducts.DataSource = products;
            ListViewProducts.DataBind();

            // Get Type
            var productType = ProductTypeFactory.GetByID(Convert.ToInt32(type));
            lblHeader.Text = productType.Title;
        }
    }
}